package com.chentf.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * @author chentengfei
 * @desc ...
 * @date 2021-01-24 21:50:51
 */
/*
       1. 额外功能
                 public class MyArround implements MethodInterceptor{
                      public Object invoke(MethodInvocation invocation){
                              Object ret = invocation.proceed();
                              return ret;
                      }
                 }
       2. 切入点
             <aop:config
                 <aop:pointcut id=""  expression="execution(* login(..))"/>
 */
@Aspect
public class MyAspect {

    //将切入点单独定义成方法,方便其他方法直接复用
    @Pointcut("execution(* *..UserServiceImpl.*(..)))")
    public void myPoincut() {
    }

    @Around(value = "myPoincut()")
    public Object arround(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("----aspect log----");
        Object ret = joinPoint.proceed();
        return ret;
    }

    @Around(value = "myPoincut()")
    public Object arround1(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("----aspect tx----");
        Object ret = joinPoint.proceed();
        return ret;
    }

}
